package LuoGu.贪心.分组;

import java.util.*;

public class Main {
    //栈
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Deque<Integer> deque = new LinkedList<>();
        int [] temp = new int [n];
        for(int i=0;i<n;i++){
            temp[i] = s.nextInt();
        }
        Arrays.sort(temp);
        int min = Integer.MAX_VALUE;
        int sum = 1;
        int tempp = temp[0];
        deque.push(temp[0]);
        for(int i=1;i<n;i++){
            tempp = deque.peek();
            if(tempp==temp[i]){
                deque.push(temp[i]);
            }else if(deque.peek()+1==temp[i]){
                deque.pop();
                sum++;
                deque.push(temp[i]);
            }else if(deque.peek()+1!=temp[i]){
                deque.pop();
                min = Math.min(min,sum);
                sum = 1;
                deque.push(temp[i]);
            }
        }
        System.out.print(min);
    }
}
